home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / mexico86.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  6KB  |  218 lines

  1. #include "driver.h"
  2.  
  3. unsigned char *mexico86_videoram,*mexico86_objectram;
  4. size_t mexico86_objectram_size;
  5. static int charbank;
  6.  
  7.  
  8. void mexico86_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  9. {
  10.     int i;
  11.  
  12.  
  13.     for (i = 0;i < Machine->drv->total_colors;i++)
  14.     {
  15.         int bit0,bit1,bit2,bit3;
  16.  
  17.  
  18.         /* red component */
  19.         bit0 = (color_prom[0] >> 0) & 0x01;
  20.         bit1 = (color_prom[0] >> 1) & 0x01;
  21.         bit2 = (color_prom[0] >> 2) & 0x01;
  22.         bit3 = (color_prom[0] >> 3) & 0x01;
  23.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  24.         /* green component */
  25.         bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  26.         bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  27.         bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  28.         bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  29.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  30.         /* blue component */
  31.         bit0 = (color_prom[2*Machine->drv->total_colors] >> 0) & 0x01;
  32.         bit1 = (color_prom[2*Machine->drv->total_colors] >> 1) & 0x01;
  33.         bit2 = (color_prom[2*Machine->drv->total_colors] >> 2) & 0x01;
  34.         bit3 = (color_prom[2*Machine->drv->total_colors] >> 3) & 0x01;
  35.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  36.  
  37.         color_prom++;
  38.     }
  39.  
  40.     /* the gfx data is inverted so we */
  41.     /* cannot use the default lookup table */
  42.     for (i = 0;i < Machine->drv->color_table_len;i++)
  43.         colortable[i] = i ^ 0x0f;
  44. }
  45.  
  46.  
  47.  
  48. WRITE_HANDLER( mexico86_bankswitch_w )
  49. {
  50.     unsigned char *RAM = memory_region(REGION_CPU1);
  51.  
  52.     if ((data & 7) > 5)
  53.         usrintf_showmessage( "Switching to invalid bank!" );
  54.  
  55.     cpu_setbank(1, &RAM[0x10000 + 0x4000 * (data & 0x07)]);
  56.  
  57.     charbank = (data & 0x20) >> 5;
  58. }
  59.  
  60.  
  61.  
  62. void mexico86_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  63. {
  64.     int offs;
  65.     int sx,sy,xc,yc;
  66.     int gfx_num,gfx_attr,gfx_offs;
  67.  
  68.  
  69.     /* Bubble Bobble doesn't have a real video RAM. All graphics (characters */
  70.     /* and sprites) are stored in the same memory region, and information on */
  71.     /* the background character columns is stored inthe area dd00-dd3f */
  72.  
  73.     /* This clears & redraws the entire screen each pass */
  74.     fillbitmap(bitmap,Machine->gfx[0]->colortable[0],&Machine->drv->visible_area);
  75.  
  76.     sx = 0;
  77. /* the score display seems to be outside of the main objectram. */
  78.     for (offs = 0;offs < mexico86_objectram_size+0x200;offs += 4)
  79.     {
  80.         int height;
  81.  
  82. if (offs >= mexico86_objectram_size && offs < mexico86_objectram_size+0x180) continue;
  83. if (offs >= mexico86_objectram_size+0x1c0) continue;
  84.  
  85.         /* skip empty sprites */
  86.         /* this is dword aligned so the UINT32 * cast shouldn't give problems */
  87.         /* on any architecture */
  88.         if (*(UINT32 *)(&mexico86_objectram[offs]) == 0)
  89.             continue;
  90.  
  91.         gfx_num = mexico86_objectram[offs + 1];
  92.         gfx_attr = mexico86_objectram[offs + 3];
  93.  
  94.         if ((gfx_num & 0x80) == 0)    /* 16x16 sprites */
  95.         {
  96.             gfx_offs = ((gfx_num & 0x1f) * 0x80) + ((gfx_num & 0x60) >> 1) + 12;
  97.             height = 2;
  98.         }
  99.         else    /* tilemaps (each sprite is a 16x256 column) */
  100.         {
  101.             gfx_offs = ((gfx_num & 0x3f) * 0x80);
  102.             height = 32;
  103.         }
  104.  
  105.         if ((gfx_num & 0xc0) == 0xc0)    /* next column */
  106.             sx += 16;
  107.         else
  108.         {
  109.             sx = mexico86_objectram[offs + 2];
  110. //            if (gfx_attr & 0x40) sx -= 256;
  111.         }
  112.         sy = 256 - height*8 - (mexico86_objectram[offs + 0]);
  113.  
  114.         for (xc = 0;xc < 2;xc++)
  115.         {
  116.             for (yc = 0;yc < height;yc++)
  117.             {
  118.                 int goffs,code,color,flipx,flipy,x,y;
  119.  
  120.                 goffs = gfx_offs + xc * 0x40 + yc * 0x02;
  121.                 code = mexico86_videoram[goffs] + ((mexico86_videoram[goffs + 1] & 0x07) << 8)
  122.                         + ((mexico86_videoram[goffs + 1] & 0x80) << 4) + (charbank << 12);
  123.                 color = ((mexico86_videoram[goffs + 1] & 0x38) >> 3) + ((gfx_attr & 0x02) << 2);
  124.                 flipx = mexico86_videoram[goffs + 1] & 0x40;
  125.                 flipy = 0;
  126. //                x = sx + xc * 8;
  127.                 x = (sx + xc * 8) & 0xff;
  128.                 y = (sy + yc * 8) & 0xff;
  129.  
  130.                 drawgfx(bitmap,Machine->gfx[0],
  131.                         code,
  132.                         color,
  133.                         flipx,flipy,
  134.                         x,y,
  135.                         &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  136.             }
  137.         }
  138.     }
  139. }
  140.  
  141. void kikikai_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  142. {
  143.     int offs;
  144.     int sx,sy,xc,yc;
  145.     int gfx_num,gfx_attr,gfx_offs;
  146.  
  147.  
  148.     /* Bubble Bobble doesn't have a real video RAM. All graphics (characters */
  149.     /* and sprites) are stored in the same memory region, and information on */
  150.     /* the background character columns is stored inthe area dd00-dd3f */
  151.  
  152.     /* This clears & redraws the entire screen each pass */
  153.     fillbitmap(bitmap,Machine->gfx[0]->colortable[0],&Machine->drv->visible_area);
  154.  
  155.     sx = 0;
  156. /* the score display seems to be outside of the main objectram. */
  157.     for (offs = 0;offs < mexico86_objectram_size+0x200;offs += 4)
  158.     {
  159.         int height;
  160.  
  161. if (offs >= mexico86_objectram_size && offs < mexico86_objectram_size+0x180) continue;
  162. if (offs >= mexico86_objectram_size+0x1c0) continue;
  163.  
  164.         /* skip empty sprites */
  165.         /* this is dword aligned so the UINT32 * cast shouldn't give problems */
  166.         /* on any architecture */
  167.         if (*(UINT32 *)(&mexico86_objectram[offs]) == 0)
  168.             continue;
  169.  
  170.         gfx_num = mexico86_objectram[offs + 1];
  171.         gfx_attr = mexico86_objectram[offs + 3];
  172.  
  173.         if ((gfx_num & 0x80) == 0)    /* 16x16 sprites */
  174.         {
  175.             gfx_offs = ((gfx_num & 0x1f) * 0x80) + ((gfx_num & 0x60) >> 1) + 12;
  176.             height = 2;
  177.         }
  178.         else    /* tilemaps (each sprite is a 16x256 column) */
  179.         {
  180.             gfx_offs = ((gfx_num & 0x3f) * 0x80);
  181.             height = 32;
  182.         }
  183.  
  184.         if ((gfx_num & 0xc0) == 0xc0)    /* next column */
  185.             sx += 16;
  186.         else
  187.         {
  188.             sx = mexico86_objectram[offs + 2];
  189. //            if (gfx_attr & 0x40) sx -= 256;
  190.         }
  191.         sy = 256 - height*8 - (mexico86_objectram[offs + 0]);
  192.  
  193.         for (xc = 0;xc < 2;xc++)
  194.         {
  195.             for (yc = 0;yc < height;yc++)
  196.             {
  197.                 int goffs,code,color,flipx,flipy,x,y;
  198.  
  199.                 goffs = gfx_offs + xc * 0x40 + yc * 0x02;
  200.                 code = mexico86_videoram[goffs] + ((mexico86_videoram[goffs + 1] & 0x1f) << 8);
  201.                 color = (mexico86_videoram[goffs + 1] & 0xe0) >> 5;
  202.                 flipx = 0;
  203.                 flipy = 0;
  204. //                x = sx + xc * 8;
  205.                 x = (sx + xc * 8) & 0xff;
  206.                 y = (sy + yc * 8) & 0xff;
  207.  
  208.                 drawgfx(bitmap,Machine->gfx[0],
  209.                         code,
  210.                         color,
  211.                         flipx,flipy,
  212.                         x,y,
  213.                         &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  214.             }
  215.         }
  216.     }
  217. }
  218.